Allow the path to be NULL, so that people can ask for information about a
authorFederico Mena Quintero <federico@ximian.com>
Mon, 15 Mar 2004 05:42:51 +0000 (05:42 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Mon, 15 Mar 2004 05:42:51 +0000 (05:42 +0000)
2004-03-14  Federico Mena Quintero  <federico@ximian.com>

* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
to be NULL, so that people can ask for information about a
parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).

* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
the condition describe above.

* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
information of root paths.

* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtkfilesystem.c
gtk/gtkfilesystemunix.c
gtk/gtkpathbar.c

index f4bd90eca892ad19f8a5d30751479b208c423e12..79d21eeaefada6ed300c9b5a1171f8d0d9b22eb2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-03-14  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+       to be NULL, so that people can ask for information about a
+       parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
+
+       * gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
+       the condition describe above.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
+       information of root paths.
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
+
 Sun Mar 14 22:32:36 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention
index f4bd90eca892ad19f8a5d30751479b208c423e12..79d21eeaefada6ed300c9b5a1171f8d0d9b22eb2 100644 (file)
@@ -1,3 +1,17 @@
+2004-03-14  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+       to be NULL, so that people can ask for information about a
+       parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
+
+       * gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
+       the condition describe above.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
+       information of root paths.
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
+
 Sun Mar 14 22:32:36 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention
index f4bd90eca892ad19f8a5d30751479b208c423e12..79d21eeaefada6ed300c9b5a1171f8d0d9b22eb2 100644 (file)
@@ -1,3 +1,17 @@
+2004-03-14  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+       to be NULL, so that people can ask for information about a
+       parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
+
+       * gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
+       the condition describe above.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
+       information of root paths.
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
+
 Sun Mar 14 22:32:36 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention
index f4bd90eca892ad19f8a5d30751479b208c423e12..79d21eeaefada6ed300c9b5a1171f8d0d9b22eb2 100644 (file)
@@ -1,3 +1,17 @@
+2004-03-14  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+       to be NULL, so that people can ask for information about a
+       parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
+
+       * gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
+       the condition describe above.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
+       information of root paths.
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
+
 Sun Mar 14 22:32:36 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention
index f4bd90eca892ad19f8a5d30751479b208c423e12..79d21eeaefada6ed300c9b5a1171f8d0d9b22eb2 100644 (file)
@@ -1,3 +1,17 @@
+2004-03-14  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+       to be NULL, so that people can ask for information about a
+       parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
+
+       * gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
+       the condition describe above.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
+       information of root paths.
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
+
 Sun Mar 14 22:32:36 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention
index 73a97ae3d37907bd025b3e460bf65a66c10239a9..4c36a05098ed7cb455843d72843d167708f2eb5b 100644 (file)
@@ -923,19 +923,17 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
 
   parent_folder = gtk_file_system_get_folder (file_system, parent_path ? parent_path : path,
                                              GTK_FILE_INFO_DISPLAY_NAME
-#if 0
-                                             | GTK_FILE_INFO_ICON
-#endif
                                              | (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
                                              error);
-  gtk_file_path_free (parent_path);
-
   if (!parent_folder)
-    return NULL;
+    goto out;
 
-  info = gtk_file_folder_get_info (parent_folder, path, error);
+  info = gtk_file_folder_get_info (parent_folder, parent_path ? path : NULL, error);
   g_object_unref (parent_folder);
 
+ out:
+
+  gtk_file_path_free (parent_path);
   return info;
 }
 
index f5b11eed1d552aa4274fdd1dfe501ddb1588898e..5ff8fecad32926c42013e028b60f1ab5138ddb3f 100644 (file)
@@ -844,7 +844,6 @@ gtk_file_folder_get_info (GtkFileFolder     *folder,
                          GError           **error)
 {
   g_return_val_if_fail (GTK_IS_FILE_FOLDER (folder), NULL);
-  g_return_val_if_fail (path != NULL, NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   return GTK_FILE_FOLDER_GET_IFACE (folder)->get_info (folder, path, error);
index 4c71b6e6fb65d93b3f323cf7267ef0af86c5fb3a..5a6d6cf0b0c57aa788d306d58f6761e539757de4 100644 (file)
@@ -465,7 +465,7 @@ gtk_file_system_unix_create_folder (GtkFileSystem     *file_system,
   const char *filename;
   gboolean result;
   char *parent, *tmp;
-  
+
   system_unix = GTK_FILE_SYSTEM_UNIX (file_system);
 
   filename = gtk_file_path_get_string (path);
@@ -475,7 +475,7 @@ gtk_file_system_unix_create_folder (GtkFileSystem     *file_system,
   tmp = remove_trailing_slash (filename);
   result = mkdir (tmp, 0777) == 0;
   g_free (tmp);
-  
+
   if (!result)
     {
       int save_errno = errno;
@@ -689,12 +689,12 @@ get_parent_dir (const char *filename)
   int len;
 
   len = strlen (filename);
-  
+
   /* Ignore trailing slashes */
   if (len > 1 && filename[len - 1] == '/')
     {
       char *tmp, *parent;
-      
+
       tmp = g_strndup (filename, len - 1);
 
       parent = g_path_get_dirname (tmp);
@@ -713,7 +713,7 @@ gtk_file_system_unix_get_parent (GtkFileSystem     *file_system,
                                 GError           **error)
 {
   const char *filename;
-  
+
   filename = gtk_file_path_get_string (path);
   g_return_val_if_fail (filename != NULL, FALSE);
   g_return_val_if_fail (g_path_is_absolute (filename), FALSE);
@@ -1485,6 +1485,26 @@ gtk_file_folder_unix_get_info (GtkFileFolder      *folder,
   gboolean file_must_exist;
   GtkFileInfoType types;
 
+  if (!path)
+    {
+      struct stat buf;
+
+      g_return_val_if_fail (filename_is_root (folder_unix->filename), NULL);
+
+      if (stat (folder_unix->filename, &buf) != 0)
+       return NULL;
+
+      info = gtk_file_info_new ();
+      gtk_file_info_set_display_name (info, "/");
+      gtk_file_info_set_is_folder (info, TRUE);
+      gtk_file_info_set_is_hidden (info, FALSE);
+      gtk_file_info_set_mime_type (info, "x-directory/normal");
+      gtk_file_info_set_modification_time (info, buf.st_mtime);
+      gtk_file_info_set_size (info, buf.st_size);
+
+      return info;
+    }
+
   filename = gtk_file_path_get_string (path);
   g_return_val_if_fail (filename != NULL, NULL);
   g_return_val_if_fail (g_path_is_absolute (filename), NULL);
@@ -1523,12 +1543,12 @@ gtk_file_folder_unix_get_info (GtkFileFolder      *folder,
       gchar *display_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
       if (!display_name)
        display_name = g_strescape (basename, NULL);
-      
+
       gtk_file_info_set_display_name (info, display_name);
-      
+
       g_free (display_name);
     }
-  
+
   if (types & GTK_FILE_INFO_IS_HIDDEN)
     gtk_file_info_set_is_hidden (info, basename[0] == '.');
 
index 770309ea1f873905438d32c0a3e44fbfa01c09db..9bf2f7a19e0bd4848c0e5a84555c4354e243640e 100644 (file)
@@ -989,13 +989,20 @@ _gtk_path_bar_set_path (GtkPathBar         *path_bar,
                                                parent_path ? parent_path : path,
                                                GTK_FILE_INFO_DISPLAY_NAME,
                                                NULL);
-      file_info = gtk_file_folder_get_info (file_folder, path, error);
+      if (!file_folder)
+       {
+         result = FALSE;
+         gtk_file_path_free (parent_path);
+         gtk_file_path_free (path);
+         break;
+       }
+
+      file_info = gtk_file_folder_get_info (file_folder, parent_path ? path : NULL, error);
       g_object_unref (file_folder);
 
       if (!file_info)
        {
          result = FALSE;
-
          gtk_file_path_free (parent_path);
          gtk_file_path_free (path);
          break;